//
//  HomeComtypeView.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/23.
//

#import "HomeComtypeView.h"

@interface HomeComtypeView()
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * infoLabel;
@end

@implementation HomeComtypeView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(4 * FMScaleX);
        make.size.mas_offset(CGSizeMake(23 * FMScaleX, 24 * FMScaleX));
        make.centerY.equalTo(@0);
    }];
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(@0);
        make.left.equalTo(self.iconView.mas_right).offset(5 * FMScaleX);
    }];
    [self addSubview:self.infoLabel];
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(5 * FMScaleX);
        make.centerY.equalTo(@0);
    }];
    
}

-(void)setIndex:(NSInteger)index{
    
    switch (index) {
        case 0:
            self.iconView.image = [UIImage imageNamed:@"Home_com_nos"];
            self.nameLabel.text = @"无色";
            self.infoLabel.text = @"没有数据";
            break;
        case 1:
            self.iconView.image = [UIImage imageNamed:@"Home_com_lus"];
            self.nameLabel.text = @"绿色";
            self.infoLabel.text = @"健康";
            break;
        case 2:
            self.iconView.image = [UIImage imageNamed:@"Home_com_lans"];
            self.nameLabel.text = @"蓝色";
            self.infoLabel.text = @"轻度亚健康又称微显性";
            break;
        case 3:
            self.iconView.image = [UIImage imageNamed:@"Home_com_huangs"];
            self.nameLabel.text = @"黄色";
            self.infoLabel.text = @"亚健康到重度亚健康";
            break;
        case 4:
            self.iconView.image = [UIImage imageNamed:@"Home_com_hongs"];
            self.nameLabel.text = @"红色";
            self.infoLabel.text = @"健康情况预警";
            break;
            
        default:
            break;
    }
    
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.image = [UIImage imageNamed:@"Home_com_nos"];
    }
    return _iconView;
}
-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Medium(13);
        _nameLabel.textColor = RDRGB(0x666666);
        _nameLabel.text = @"黑色";
    }
    return _nameLabel;
}
-(UILabel *)infoLabel{
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc]init];
        _infoLabel.text = @"代表没有数据";
        _infoLabel.font = Regular(12);
        _infoLabel.textColor = RDRGB(0x999999);
    }
    return _infoLabel;
}
@end
